package casa.depesos.app.com.http.req;


import java.util.Map;

import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.GetCodeBean;
import casa.depesos.app.com.http.data.CodeType;
import casa.depesos.app.com.http.parser.GetCodeParser;

public class GetCodeReq implements HttpReq<GetCodeBean> {
    String phone;
    CodeType type;

    public GetCodeReq(String phone, CodeType type) {
        this.phone = phone;
        this.type = type;
    }

    @Override
    public void req(ReqCallback callback) {//   /app/user/getMobileCode
        if (type == CodeType.BIND) {
            req("/app/cardBinding/retrieveCardSecurityCode", new GetCodeParser(), callback);
        } else {
            req("/app/consumer/retrieveSecurityPin", new GetCodeParser(), callback);
        }
    }

    @Override
    public Map getBody() {
        Map map = HttpReq.super.getBody();
        if (type != CodeType.BIND) {
            map.put("mobile", phone);
            map.put("useCase", type.str());
        }
        return map;
    }
}
